home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 23 / CU Amiga - Super CD-ROM 23 (June 1998).iso / CreatingGames / Utilities / Misc / GMS / GMSDev / Source / Asm / Chunky / ChunkyBuffered.s < prev    next >
Encoding:
Text File  |  1997-12-23  |  5.0 KB  |  219 lines

  1. ;-------T-------T------------------------T----------------------------------;
  2. ;Name:      Chunky Pixel List (Buffered)
  3. ;Author:    Paul Manias
  4. ;Copyright: DreamWorld Productions (c) 1996-1997.  Freely distributable.
  5. ;
  6. ;This demo is like the other pixel list demos but uses a CHUNKY8 screen type.
  7. ;Then screen size has been kept very small as the C2P routine is too slow,
  8. ;but this will be improved in the next version.  The good thing is that
  9. ;because the routine is transparent, using a graphics card would mean that
  10. ;this demo would run at the maximum possible speed.
  11. ;
  12. ;Press LMB to exit.
  13.  
  14.     INCDIR    "INCLUDES:"
  15.     INCLUDE    "dpkernel/dpkernel.i"
  16.  
  17.     SECTION    "Demo",CODE
  18.  
  19. ;===========================================================================;
  20. ;                             INITIALISE DEMO
  21. ;===========================================================================;
  22.  
  23.     STARTDPK
  24.  
  25. Start:    MOVEM.L    A0-A6/D1-D7,-(SP)
  26.     move.l    DPKBase(pc),a6
  27.     lea    ScreenTags(pc),a0
  28.     sub.l    a1,a1
  29.     CALL    Init
  30.     tst.l    d0
  31.     beq.s    .Exit
  32.  
  33.     moveq    #ID_JOYDATA,d0    ;Get joydata structure.
  34.     CALL    Get
  35.     move.l    d0,JoyData
  36.     beq.s    .Exit
  37.     move.l    d0,a0    ;Initialise the joydata structure.
  38.     sub.l    a1,a1
  39.     CALL    Init
  40.     tst.l    .Exit
  41.  
  42.     move.l    Screen(pc),a0
  43.     CALL    Display
  44.  
  45.     bsr.s    Main
  46.  
  47. .Exit    move.l    DPKBase(pc),a6
  48.     move.l    JoyData(pc),a0
  49.     CALL    Free
  50.     move.l    Screen(pc),a0
  51.     CALL    Free
  52.     MOVEM.L    (SP)+,A0-A6/D1-D7
  53.     moveq    #ERR_OK,d0
  54.     rts
  55.  
  56. ;===========================================================================;
  57. ;                                MAIN LOOP
  58. ;===========================================================================;
  59.  
  60. Main:
  61. .loop    move.l    BLTBase(pc),a6
  62.     move.l    Screen(pc),a1
  63.     move.l    GS_Bitmap(a1),a0
  64.     CALL    bltClearBitmap
  65.  
  66.     lea    MList(pc),a2    ;a2 = Pointer to pixel list.
  67.     move.l    a2,a3    ;Drop the pixels here.
  68.     moveq    #31-1,d7
  69. .drop    addq.w    #1,2(a3)    ;a3 = YCoord+1
  70.     subq.l    #1,4(a3)    ;a3 = (Colour)-1
  71.     bge.s    .colok
  72.     clr.l    4(a3)
  73. .colok    addq.w    #8,a3
  74.     dbra    d7,.drop
  75.  
  76.     move.l    DPKBase(pc),a6
  77.     lea    MouseX(pc),a5
  78.     move.l    JoyData(pc),a0
  79.     CALL    Query
  80.  
  81.     move.l    JoyData(pc),a0
  82.     move.l    JD_Buttons(a0),d0
  83.     btst    #JB_LMB,d0
  84.     bne    .done
  85.  
  86.     move.w    JD_XChange(a0),d0
  87.     move.w    JD_YChange(a0),d1
  88.  
  89.     move.l    Screen(pc),a0    ;a0 = Screen.
  90.     add.w    (a5),d0    ;d0 = (MouseX)+ChangeX
  91.     add.w    2(a5),d1    ;d1 = (MouseY)+ChangeY
  92.  
  93. .ChkRX    cmp.w    GS_Width(a0),d0
  94.     blt.s    .ChkLX
  95.     moveq    #$00,d0
  96.     bra.s    .Calculate
  97.  
  98. .ChkLX    tst.w    d0
  99.     bgt.s    .ChkTY
  100.     move.w    GS_Width(a0),d0
  101.     bra.s    .Calculate
  102.  
  103. .ChkTY    tst.w    d1
  104.     bgt.s    .ChkBY
  105.     move.w    GS_Height(a0),d1
  106.     bra.s    .Calculate
  107.  
  108. .ChkBY    cmp.w    GS_Height(a0),d1
  109.     blt.s    .Calculate
  110.     moveq    #$00,d1
  111.  
  112. .Calculate
  113.     move.w    d0,(a5)
  114.     move.w    d1,2(a5)
  115.  
  116.     move.l    (a5),-(sp)
  117.     moveq    #2,d1
  118.     CALL    FastRandom
  119.     subq.w    #1,d0
  120.     add.w    d0,(a5)
  121.  
  122.     moveq    #2,d1
  123.     CALL    FastRandom
  124.     subq.w    #1,d0
  125.     add.w    d0,2(a5)
  126.  
  127.     move.l    a2,a3
  128.     moveq    #31-1,d7
  129. .tloop    move.l    8(a3),(a3)
  130.     move.l    12(a3),4(a3)
  131.     addq.w    #8,a3
  132.     dbra    d7,.tloop
  133.  
  134.     move.l    BLTBase(pc),a6
  135.     move.l    Screen(pc),a0
  136.     move.l    GS_Bitmap(a0),a0
  137.     lea    PixelList(pc),a1    ;a1 = Pixel list.
  138.     CALL    bltDrawPixelList    ;>> = Draw pixels with clipping.
  139.     move.l    (sp)+,(a5)
  140.  
  141.     move.l    SCRBase(pc),a6
  142.     CALL    scrWaitAVBL
  143.  
  144.     move.l    Screen(pc),a0
  145.     CALL    scrSwapBuffers
  146.     bra    .loop
  147.  
  148. .done    rts
  149.  
  150. ;===========================================================================;
  151. ;                                  DATA
  152. ;===========================================================================;
  153.  
  154. JoyData:    dc.l  0
  155.  
  156. ScreenTags:    dc.l  TAGS_SCREEN
  157. Screen:        dc.l  0
  158.         dc.l  GSA_Width,256
  159.         dc.l  GSA_Height,128
  160.         dc.l  GSA_Palette,.palette
  161.         dc.l  GSA_Attrib,CENTRE|DBLBUFFER
  162.         dc.l    GSA_BitmapTags,0
  163.         dc.l    BMA_Type,CHUNKY8
  164.         dc.l    TAGEND,0
  165.         dc.l  TAGEND
  166.  
  167. .palette    dc.l  PALETTE,32
  168.         dc.l  $000000,$101010,$171717,$202020,$272727,$303030
  169.         dc.l  $373737,$404040,$474747,$505050,$575757,$606060
  170.         dc.l  $676767,$707070,$777777,$808080,$878787,$909090
  171.         dc.l  $979797,$a0a0a0,$a7a7a7,$b0b0b0,$b7b7b7,$c0c0c0
  172.         dc.l  $c7c7c7,$d0d0d0,$d7d7d7,$e0e0e0,$e0e0e0,$f0f0f0
  173.         dc.l  $f7f7f7,$ffffff
  174.  
  175. PixelList:    dc.w   32,PXL_SIZEOF    ;Amount of entries, EntrySize.
  176.         dc.l   MList    ;Pointer to pixel list array.
  177. MList:        PIXEL  16,12,00    ;First pixel to draw (at back)
  178.         PIXEL  16,12,00    ;X/Y/Colour
  179.         PIXEL  16,12,00    ;..
  180.         PIXEL  16,12,00    ;..
  181.         PIXEL  16,12,00    ;..
  182.         PIXEL  16,12,00    ;..
  183.         PIXEL  16,12,00    ;..
  184.         PIXEL  16,12,00    ;..
  185.         PIXEL  16,12,00    ;..
  186.         PIXEL  16,12,00    ;..
  187.         PIXEL  16,12,00    ;..
  188.         PIXEL  16,12,00    ;..
  189.         PIXEL  16,12,00    ;..
  190.         PIXEL  16,12,00    ;..
  191.         PIXEL  16,12,00    ;..
  192.         PIXEL  16,12,00    ;..
  193.         PIXEL  16,12,00    ;..
  194.         PIXEL  16,12,00    ;..
  195.         PIXEL  16,12,00    ;..
  196.         PIXEL  16,12,00    ;..
  197.         PIXEL  16,12,00    ;..
  198.         PIXEL  16,12,00    ;..
  199.         PIXEL  16,12,00    ;..
  200.         PIXEL  16,12,00    ;..
  201.         PIXEL  16,12,00    ;..
  202.         PIXEL  16,12,00    ;..
  203.         PIXEL  16,12,00    ;..
  204.         PIXEL  16,12,00    ;..
  205.         PIXEL  16,12,00    ;..
  206.         PIXEL  16,12,00    ;..
  207.         PIXEL  16,12,00    ;..
  208. MouseX:        PIXEL  16,12,31    ;Last pixel to draw (in front)
  209.  
  210. ;===========================================================================;
  211.  
  212. ProgName:    dc.b  "Chunky Buffered",0
  213. ProgAuthor:    dc.b  "Paul Manias",0
  214. ProgDate:    dc.b  "December 1997",0
  215. ProgCopyright:    dc.b  "DreamWorld Productions (c) 1996-1997.  Freely distributable.",0
  216. ProgShort:    dc.b  "Chunky double buffering.",0
  217.         even
  218.  
  219.